package org.example.gykexamproject03.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.gykexamproject03.entity.T_user;
import org.example.gykexamproject03.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.swing.*;
import java.util.List;


@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,T_user> implements UserService {
    @Override
    public T_user login(T_user user) {
        //通过用户名或者邮箱或者于机号去查询用户是否存在
        QueryWrapper<T_user> qw= new QueryWrapper<>();
        qw.eq("loginname",user.getUsername()).or().eq("tel",user.getUsername()).or().eq( "email",user.getUsername());
        T_user one = getOne(qw);
        //判断是否查询到这个用户
        if(one!=null){
            //说明查询到这个用户，判断密码是否正确
            if(one.getPassword().equals(user.getPassword())){
                //登录成功
                return one;
            }
        }
        return null;
    }

}
